<%@ page language="java" pageEncoding="UTF-8" %>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
    <title>后台</title>
    <meta http-equiv="content-type" content="text/html; charset=UTF-8">

    <%-- 自定义CSS样式 --%>
    <link href="<%=request.getContextPath()%>/mycss/my-loading.css" rel="stylesheet" type="text/css"/>
    <link href="<%=request.getContextPath()%>/mycss/my-icon.css" rel="stylesheet" type="text/css"/>
    <%-- <link href="mycss/ext-patch.css" rel="stylesheet" type="text/css"/>--%>
    <%-- Ext必需的js/css文件 --%>
    <link href="<%=request.getContextPath()%>/resources/css/ext-all.css" rel="stylesheet" type="text/css"/>
    <link href="<%=request.getContextPath()%>/resources/css/file-upload.css" rel="stylesheet" type="text/css"/>
    <script language="javascript" src="<%=request.getContextPath()%>/js/ext-base.js"></script>
    <script language="javascript" src="<%=request.getContextPath()%>/js/ext-all.js"></script>
    <script language="javascript" src="<%=request.getContextPath()%>/js/ext-lang-zh_CN.js"></script>
    <script language="javascript" src="<%=request.getContextPath()%>/js/TabCloseMenu_extjs_2.2.js"></script>
    <script language="javascript" src="<%=request.getContextPath()%>/js/FileUploadField.js"></script>
    <%-- fusionchart 库文件 --%>
    <script type="text/javascript" src="<%=request.getContextPath()%>/js/FusionCharts.js"></script>

    <!-- 自定义工具类 -->
    <script type="text/javascript" src="<%=request.getContextPath()%>/myjs/utils/GridPanelUtils.js"></script>
    <script type="text/javascript" src="<%=request.getContextPath()%>/myjs/utils/StarHtmleditor.js"></script>
    <%-- 主页 --%>
    <script type="text/javascript" src="<%=request.getContextPath()%>/myjs/main.js"></script>
    <!-- 我的开始 权限列表-->
    <script type="text/javascript" src="<%=request.getContextPath()%>/myjs/permission/permissionList.js"></script>
    <script type="text/javascript" src="<%=request.getContextPath()%>/myjs/permission/PermissionForm.js"></script>
    <script type="text/javascript" src="<%=request.getContextPath()%>/myjs/permission/AddPermissionWindow.js"></script>
    <script type="text/javascript" src="<%=request.getContextPath()%>/myjs/permission/EditPermissionWindow.js"></script>
    <!-- Role-->

    <script type="text/javascript">
        Ext.onReady(function () {

            Ext.UserName = "你好";
            //alert(Ext.UserName);
            Ext.BLANK_IMAGE_URL = '<%=request.getContextPath()%>/resources/images/default/tree/s.gif';

            Ext.apply(Ext.form.TextField.prototype, {
                validator:function (text) {
                    if (this.allowBlank == false
                            && Ext.util.Format.trim(text).length == 0)
                        return false;
                    else
                        return true;
                }
            });
            Ext.override(Ext.form.BasicForm, {
                findField:function (id) {
                    // alert(id);
                    var field = this.items.get(id);
                    if (!field) {
                        this.items.each(function (f) {
                            if (f.isXType('radiogroup') || f.isXType('checkboxgroup') || f.isXType('remotecheckboxgroup')) {
                                f.items.each(function (c) {
                                    if (c.isFormField && (c.dataIndex == id || c.id == id || c.getName() == id)) {
                                        field = c;
                                        return false;
                                    }
                                });
                            }

                            if (f.isFormField && (f.dataIndex == id || f.id == id || f.getName() == id)) {
                                field = f;
                                return false;
                            }
                        });
                    }
                    //alert(field.name);
                    return field || null;
                }
            });
            Ext.override(Ext.form.CheckboxGroup, {
                getValue:function () {
                    var v = [];
                    this.items.each(function (item) {

                        if (item.getValue()) {

                            v.push(item.getRawValue());

                        } else {

                            v.push('');

                        }

                    });

                    return v;

                },

                setValue:function (vals) {
                    // alert(vals);
                    // alert(Ext.isArray(vals));
                    var a = [];

                    if (Ext.isArray(vals)) {

                        a = vals;

                    } else {

                        a = [vals];

                    }

                    this.items.each(function (item) {

                        item.setValue(false); // reset value
                        if (a.indexOf(item.inputValue) > -1) {   //從數據庫中提取數據，與頁面上checkbox的inputValue對比來判斷是否選中。
                            item.setValue(true);    //可理解為以下：
                        }
                        /*  for (var i = 0; i < a.length; i ++) {

                         var val = a[i];
                         //alert(val)
                         if (val == item.getRawValue()) {

                         item.setValue(true);

                         }

                         }*/


                    });

                }

            });
            <%-- 加载效果 --%>
            setTimeout(function () {
                Ext.get('loading').remove();
                Ext.get('loading-mask').fadeOut({remove:true});
            }, 1000);
            <%-- 开启提示 --%>
            Ext.QuickTips.init();
            Ext.form.Field.prototype.msgTarget = "side";
            <%-- 实例化主页 --%>
            var _index = new Main();

            <%-- 窗体大小改变延时事件 --%>
            window.onresize = function () {
                <%-- 过100毫秒在执行  --%>

                setTimeout(_index.onActiveTabSize, 100);
            };
        });
    </script>
</head>

<body>
<div id="loading">
    <div class="loading-indicator">
        <img src="<%=request.getContextPath()%>/images/extanim32.gif" alt="" width="32" height="32"
             style="margin-right:8px;" align="absmiddle"/>
        正在加载,请稍候......
    </div>
</div>
<div id="loading-mask">
</div>
</body>
</html>
